package com.py.inbound.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.py.inbound.domain.PyInbound;
import com.py.inbound.domain.WhOutbound;
import com.py.inbound.service.IWhOutboundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 出库管理Controller
 *
 * @author ruoyi
 * @date 2024-12-19
 */
@RestController
@RequestMapping("/outbound")
public class WhOutboundController extends BaseController {
    @Autowired
    private IWhOutboundService whOutboundService;

    /**
     * 查询出库管理列表
     */
    @RequiresPermissions("outbound:outbound:list")
    @GetMapping("/list")
    public TableDataInfo list(WhOutbound whOutbound) {
        startPage();
        List<WhOutbound> list = whOutboundService.selectWhOutboundList(whOutbound);
        return getDataTable(list);
    }

    /**
     * 导出出库管理列表
     */
    @RequiresPermissions("outbound:outbound:export")
    @Log(title = "出库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WhOutbound whOutbound) {
        List<WhOutbound> list = whOutboundService.selectWhOutboundList(whOutbound);
        ExcelUtil<WhOutbound> util = new ExcelUtil<WhOutbound>(WhOutbound.class);
        util.exportExcel(response, list, "出库管理数据");
    }

    /**
     * 获取出库管理详细信息
     */
    @RequiresPermissions("outbound:outbound:query")
    @GetMapping(value = "/{outboundId}")
    public AjaxResult getInfo(@PathVariable("outboundId") Long outboundId) {
        return success(whOutboundService.selectWhOutboundByOutboundId(outboundId));
    }

    /**
     * 新增出库管理
     */
    @RequiresPermissions("outbound:outbound:add")
    @Log(title = "出库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WhOutbound whOutbound) {
        return toAjax(whOutboundService.insertWhOutbound(whOutbound));
    }

    /**
     * 修改出库管理
     */
    @RequiresPermissions("outbound:outbound:edit")
    @Log(title = "出库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WhOutbound whOutbound) {
        return toAjax(whOutboundService.updateWhOutbound(whOutbound));
    }

    /**
     * 删除出库管理
     */
    @RequiresPermissions("outbound:outbound:remove")
    @Log(title = "出库管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{outboundIds}")
    public AjaxResult remove(@PathVariable Long[] outboundIds) {
        return toAjax(whOutboundService.deleteWhOutboundByOutboundIds(outboundIds));
    }

    @PostMapping("/WhOutboundLS")
    public TableDataInfo WhOutboundLS(@RequestBody WhOutbound whOutbound) {
        startPage();
        List<WhOutbound> list = whOutboundService.WhOutboundLS(whOutbound);
        return getDataTable(list);
    }

    @GetMapping("/outTotle")
    public WhOutbound outTotle() {
        return whOutboundService.outTotle();
    }
}
